import axios from 'axios'
const instance = axios.create({
    baseURL: '',
    timeout: 15 * 1000,
    withCredentials: true
})

// 请求拦截
instance.interceptors.request.use(config => {
    return config;
})

// 返回拦截
instance.interceptors.response.use(response => {
    // 这里可进行返回数据的格式化等操作
    return new Promise((resolve, reject) => {
        if (response.status != 200 || response.data.code != 0) {
            reject(response.data)
        } else {
            resolve(response.data)
        }
    })
});

export default instance;